package com.loadburn.heron.storage.dao;

import com.loadburn.heron.storage.sql.Page;

import java.io.Serializable;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

/**
 * @author slacrey (scstlinfeng@yahoo.com)
 *         Date: 13-12-25
 */
public interface BaseDao<T> {

    public boolean save(T t) throws SQLException;
    public boolean remove(T t) throws SQLException;
    public boolean update(T t, Long primaryKey) throws SQLException;

    public List<T> findAll() throws SQLException;
    public List<T> findByQueryName(String name, Map<String, Object> nameParams) throws SQLException;
    public Page<T> paginateAll(Page<T> page) throws SQLException;
    public Page<T> paginateByQueryName(String name, Map<String, Object> nameParams, Page<T> page) throws SQLException;
    public T findById(Long primaryKey) throws SQLException;

    public void save(List<T> entities) throws SQLException;
    public void delete(List<? extends T> entities) throws SQLException;

    public void deleteAll() throws SQLException;
    public long count() throws SQLException;

    public long count(String name, Map<String, Object> nameParams) throws SQLException;

}
